package gw.com.android.ui.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gwtsz.gts2.hx.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import gw.com.android.app.AppMain;
import gw.com.android.utils.ColorThemeUtil;

/**
 * Created by reeta.zou on 2016/9/5.
 * 下单界面相关范围控件
 */
public class TitleRangeView extends LinearLayout{

    @BindView(R.id.title_view)
    TextView mTitleView;
    @BindView(R.id.title_view_range)
    TextView mRangeView;

    public TitleRangeView(Context context) {
        super(context);
        init(context);
    }

    public TitleRangeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TitleRangeView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context){
        View view = LayoutInflater.from(context).inflate(R.layout.order_title_range_view, this, true);
        ButterKnife.bind(this, view);
    }

    /**
     * 设置title文案
     * @param viewID
     */
    public void setTitleView(int viewID){
       if(null != mTitleView){
           mTitleView.setText(AppMain.getAppString(viewID));
       }
    }

    /**
     * 设置title文案
     * @param title
     */
    public void setTitleView(String title){
        if(null != mTitleView){
            mTitleView.setText(title);
        }
    }

    /**
     * 设置range文案
     * @param title
     */
    public void setRangeView(String title){
        if(null != mRangeView){
            mRangeView.setText(title);
        }
    }

    /**
     * 设置range文案
     * @param leftTitle 左边间距值
     * @param rightTitle 右边间距值
     */
    public void setRangeView(String leftTitle, String rightTitle){
        if(null != mRangeView){
            mRangeView.setText(AppMain.getAppString(R.string.order_range_tips,leftTitle, rightTitle));
        }
    }

    /**
     * 设置默认文案颜色
     */
    public void setDefalutColor(){
        mTitleView.setTextColor(ColorThemeUtil.instance().color_b);
        mRangeView.setTextColor(ColorThemeUtil.instance().color_h);
    }

    /**
     * 设置超过范围值的数据的文案颜色
     */
    public void setErrorColor(){
        mTitleView.setTextColor(ColorThemeUtil.instance().color_red);
        mRangeView.setTextColor(ColorThemeUtil.instance().color_red);
    }
}
